package com.qili.service.supervisor.impl;

import com.qili.base.mapper.BaseMapper;
import com.qili.base.service.impl.BaseServiceImpl;
import com.qili.entity.supervisor.ProjectUnitConstruction;
import com.qili.entity.supervisor.dto.ProjectUnitConstructionDTO;
import com.qili.mapper.supervisor.ProjectUnitConstructionMapper;
import com.qili.service.supervisor.ProjectUnitConstructionService;
import com.qili.util.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by lenovo on 2020/11/2.
 */
@Service
public class ProjectUnitConstructionServiceImpl extends BaseServiceImpl<ProjectUnitConstruction, String> implements ProjectUnitConstructionService {

    @Autowired
    ProjectUnitConstructionMapper projectUnitConstructionMapper;

    @Override
    public BaseMapper<ProjectUnitConstruction, String> getMappser() {
        return projectUnitConstructionMapper;

    }
    /**
    * @Author:zhaoyongke
    * @Description: 查询分包
    * @param dto
    * @Date:10:40 2020/12/11
    */
    public List<ProjectUnitConstructionDTO> selectProjectUnitList(ProjectUnitConstructionDTO dto) {
        List<ProjectUnitConstructionDTO> list = projectUnitConstructionMapper.selectProjectUnitList(dto);
        return list;
    }
    /**
     * @Author:Zhangshuo
     * @Description:
     * @param ids
     * @Date:20:52 2020-12-11
     */
    @Override
    public int deleteByProjectIds(String[] ids) {
        return projectUnitConstructionMapper.deleteByProjectIds(ids);
    }

    /**
     * @Author:zhaoyongke
     * @Description:是否是承建单位  根据当前用户判断
     * @param projectId
     * @Date:17:23 2021/1/6
     */
    public Boolean isCjUser(String projectId){
        String userId= CommonUtil.getUserId();
        ProjectUnitConstruction projectUnitConstruction = new ProjectUnitConstruction();
        projectUnitConstruction.setSupervisorProjectId(projectId);
        projectUnitConstruction.setProjectManager(userId);
        int  count= projectUnitConstructionMapper.selectCount(projectUnitConstruction);
        if(count>0){
            return true;
        }else{
            return false;
        }
    }
    public Boolean isCjUserJlApp(String projectId,String userId){
        ProjectUnitConstruction projectUnitConstruction = new ProjectUnitConstruction();
        projectUnitConstruction.setSupervisorProjectId(projectId);
        projectUnitConstruction.setProjectManager(userId);
        int  count= projectUnitConstructionMapper.selectCount(projectUnitConstruction);
        if(count>0){
            return true;
        }else{
            return false;
        }
    }



}
